package com.zcf.zcf_uitls;

import com.zcf.gameController.F_Websocket_s;
import com.zcf.gameController.WebSocketBull;
import com.zcf.pojo.Msg;
import com.zcf.pojo.RoomsParam;
import com.zcf.pojo.UserBean;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * @author jj
 * @date 2019/11/11 18:03
 */
public class JoinRoom {

/*
   */
/**
   * @description :加入房间
   * @param user
   * @date : 2019/11/11 18:04
   * @author : jj
   *//*

    public static Msg joinRoom(UserBean user,String roomName) {
        Msg msgs = null;
        Msg being = isBeing(user, msgs);
        if (being!=null){
            return msgs;
        }
        return msgs;
    }
*/

    /**
    * @description :判断是否在房间内
    * @date : 2019/11/11 18:15
    * @author : jj
    */
    public static Msg isBeing(UserBean user ,Map<String, Object> data){
        Msg msgs=null;
        Collection<RoomsParam> values_w = WebSocketBull.rooms.values();
        Collection<RoomsParam> values_f = F_Websocket_s.rooms.values();
        for (RoomsParam rParam : values_w) {
            if(rParam.getUsers().get(String.valueOf(user.getId())) != null){
                msgs = new Msg(320,"玩家还在推筒子房间内无法加入新游戏,是否重连",0,"joinRoom");
                return msgs;
            }
        }
        for (RoomsParam rParam : values_f) {
            if(rParam.getUsers().get(String.valueOf(user.getId())) != null){
                msgs = new Msg(320,"玩家还在三公房间内无法加入新游戏,是否重连",1,"joinRoom");
                return msgs;
            }
        }
        return null;
    }

}
